<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button class="btn">测试 ajax</button>
    <p></p>
    <script>
      const btn = document.querySelector('.btn')
      const p = document.querySelector('p')
      btn.addEventListener('click', function () {
        // 异步对象，小黄人对象
        var oReq = new XMLHttpRequest()
        oReq.addEventListener('load', function () {
          // console.log(this.responseText)
          // alert(this.responseText)
          p.innerHTML = this.responseText
        })
        oReq.open('GET', 'https://api-vue-base.itheima.net/api/joke')
        oReq.send()
      })

      // axios({
      //   url: '',
      //   method: '',
      // }).then(res => {
      //   p.innerHTML = this.responseText
      // })
    </script>
  </body>
</html>
